﻿/*******************************************************************************
 * Copyright © 2016 DJY 版权所有
 * Author: DJY
 * Description: 后台管理系统
 * Website：http://www.djyweb.cn
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DJY.Code
{
    public interface ICache
    {
        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="cacheKey">缓存键</param>
        /// <returns></returns>
        T GetCache<T>(string cacheKey);

        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="cacheKey">缓存键</param>
        /// <param name="obj">缓存对象</param>
        void SetCache(string cacheKey, object obj);

        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="cacheKey">缓存键</param>
        /// <param name="obj">缓存对象</param>
        /// <param name="expireTime">绝对过期时间</param>
        void SetCache(string cacheKey,object obj, DateTime expireTime);

        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="cacheKey">缓存键</param>
        /// <param name="obj">缓存对象</param>
        /// <param name="noSlidingExpiration">相对过期时间</param>
        void SetCache(string cacheKey, object obj, TimeSpan noSlidingExpiration);

        /// <summary>
        /// 移除缓存
        /// </summary>
        /// <param name="cacheKey">缓存键</param>
        void RemoveCache(string cacheKey);

        /// <summary>
        /// 清空缓存
        /// </summary>
        void RemoveCache();
    }
}
